package com.pig4cloud.pigx.user.api.feign;

import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
import com.pig4cloud.pigx.common.core.constant.ServiceNameConstants;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.user.entity.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;

/**
 * 用户模块-用户feign接口
 *
 * @since 2022/12/11 16:51
 */
@FeignClient(contextId = "feignUser",
        value = ServiceNameConstants.USER_SERVICE,
        path = "/feign/user")
public interface UserFeign {

    /**
     * 根据用户id查询用户
     *
     * @param userId 用户id
     * @param from   标记请求来自系统内部
     * @return {@link R <User>}
     * @since 2022/12/11 16:50
     */
    @GetMapping("/{userId}")
    R<User> getById(@PathVariable("userId") Long userId, @RequestHeader(SecurityConstants.FROM) String from);

}
